package com.ruoyi.system.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Scenicarea;
import com.ruoyi.system.service.IScenicAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: ZCJ
 * @date: 2024/06/26/19:55
 * @desc:
 */
@RestController
@RequestMapping("/scenic/area")
public class ScenicAreaController extends BaseController {

    @Autowired
    private IScenicAreaService scenicareaService;

    /**
     * 查询列表
     */
    @PreAuthorize("@ss.hasPermi('system:scenicarea:list')")
    @GetMapping
    public TableDataInfo list(Scenicarea scenicarea)
    {
        startPage();
        List<Scenicarea> list = scenicareaService.selectScenicareaList(scenicarea);
        return getDataTable(list);
    }

    /**
     * 获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:scenicarea:query')")
    @GetMapping(value = "/{areaId}")
    public AjaxResult getInfo(@PathVariable("areaId") Integer areaId)
    {
        return success(scenicareaService.selectScenicareaByAreaId(areaId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:scenicarea:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Scenicarea scenicarea)
    {
        return toAjax(scenicareaService.insertScenicarea(scenicarea));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:scenicarea:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Scenicarea scenicarea)
    {
        return toAjax(scenicareaService.updateScenicarea(scenicarea));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:scenicarea:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{areaIds}")
    public AjaxResult remove(@PathVariable Long[] areaIds)
    {
        return toAjax(scenicareaService.deleteScenicareaByAreaIds(areaIds));
    }

}
